import request from '../../utils/request.js';
const state = {
	indexData:{},
	indexList:[]
}
const mutations = {
	GET_INDEXDATA(state,indexData){
		state.indexData = indexData
	},
	GET_INDEXCATELIST(state,indexList){
		state.indexList = indexList
	}
}
const actions = {
	async getIndexData({commit}){
		const result = await request('/getIndexData')
		commit('GET_INDEXDATA',result)
		// console.log(result)
	},
	async getIndexCateList({commit}){
		const result = await request('/getIndexCateList')
		commit('GET_INDEXCATELIST',result)
		console.log(result)
	}
}
const getters = {
	// 因为返回回来的数据太复杂通过getters计算出需要的数据
	navData(){
		// 为了防止假报错需要进行判断
		return (state.indexData.kingKongModule?state.indexData.kingKongModule:{}).kingKongList
	},
	// 计算图标数据
	iconData(){
		return state.indexData.policyDescList || []
	},
	// 计算楼层的数据
	floorList(){
		return state.indexData.categoryModule || []
	}
}

export default {
	state,
	mutations,
	actions,
	getters
}